%     AERO LOAD - программа для нагружения агрегатов самолета распределенной нагрузкой
%     Copyright (C) 2018-2024  Михаил Козлов
%     Сайт проекта: <http://www.fastenerdoctor.ru/>
%     Адрес электронной почты для связи с разработчиком:
%     <doctor.fastener@gmail.com>
% 
%     Эта программа является свободным программным обеспечением: Вы можете
%     распространять ее и/или изменять, соблюдая условия Универсальной общественной
%     лицензии GNU, опубликованной Фондом свободного программного обеспечения,
%     либо редакции 3, либо (на Ваше усмотрение) любой редакции, выпущенной позже.
% 
%     Эта программа распространяется в надежде на то, что она окажется полезной,
%     но БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ, включая даже подразумеваемую гарантию ТОВАРНОЙ ПРИГОДНОСТИ,
%     либо ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЕННЫХ ЦЕЛЕЙ. Ознакомьтесь с Универсальной общественной
%     лицензией GNU для получения более подробной информации.
% 
%     Вы должны были получить копию Универсальной общественной лицензии GNU
%     вместе с этой программой. Если Вы ее не получили, то перейдите по адресу:
%     <http://www.gnu.org/licenses/>.
% 
%     This program is free software: you can redistribute it and/or modify
%     it under the terms of the GNU General Public License as published by
%     the Free Software Foundation, either version 3 of the License, or
%     (at your option) any later version.
% 
%     This program is distributed in the hope that it will be useful,
%     but WITHOUT ANY WARRANTY; without even the implied warranty of
%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%     GNU General Public License for more details.
% 
%     You should have received a copy of the GNU General Public License
%     along with this program.  If not, see <https://www.gnu.org/licenses/>.

function Distribution = Access_Model_X(Z, Load)

global Stair_Parameter;

Distribution = [];

switch Load.Chord_Pressure.Law
        
    case 'MODEL_1'
        
        switch Load.Chord_Pressure.Model_X_p2_p1_Type
            case 'CONSTANT'
                p2_p1_Distr = zeros(2,2);
                p2_p1_Distr(1,1) = 0;
                p2_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
                p2_p1_Distr(2,1) = 1;
                p2_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
            case 'DISTRIBUTION'
                p2_p1_Distr = Load.Chord_Pressure.Model_X_p2_p1_Distr_Data;
        end
        
        switch Load.Chord_Pressure.Model_X_f_Type
            case 'CONSTANT'
                f_Distr = zeros(2,2);
                f_Distr(1,1) = 0;
                f_Distr(1,2) = Load.Chord_Pressure.Model_X_f_Value;
                f_Distr(2,1) = 1;
                f_Distr(2,2) = Load.Chord_Pressure.Model_X_f_Value;
            case 'DISTRIBUTION'
                f_Distr = Load.Chord_Pressure.Model_X_f_Distr_Data;
        end
        
        p2_p1 = Access_Array(p2_p1_Distr, Z, Load.Extrapolation.Model_X_p2_p1_0, Load.Extrapolation.Model_X_p2_p1_1);
        f = Access_Array(f_Distr, Z, Load.Extrapolation.Model_X_f_0, Load.Extrapolation.Model_X_f_1);
        
        Distribution = zeros(3,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f;
        Distribution(2,2) = p2_p1;
        Distribution(3,1) = 1;
        Distribution(3,2) = p2_p1;
        
    case 'MODEL_2'
        
        switch Load.Chord_Pressure.Model_X_p2_p1_Type
            case 'CONSTANT'
                p2_p1_Distr = zeros(2,2);
                p2_p1_Distr(1,1) = 0;
                p2_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
                p2_p1_Distr(2,1) = 1;
                p2_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
            case 'DISTRIBUTION'
                p2_p1_Distr = Load.Chord_Pressure.Model_X_p2_p1_Distr_Data;
        end
        
        switch Load.Chord_Pressure.Model_X_p3_p1_Type
            case 'CONSTANT'
                p3_p1_Distr = zeros(2,2);
                p3_p1_Distr(1,1) = 0;
                p3_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p3_p1_Value;
                p3_p1_Distr(2,1) = 1;
                p3_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p3_p1_Value;
            case 'DISTRIBUTION'
                p3_p1_Distr = Load.Chord_Pressure.Model_X_p3_p1_Distr_Data;
        end
        
        switch Load.Chord_Pressure.Model_X_f_Type
            case 'CONSTANT'
                f_Distr = zeros(2,2);
                f_Distr(1,1) = 0;
                f_Distr(1,2) = Load.Chord_Pressure.Model_X_f_Value;
                f_Distr(2,1) = 1;
                f_Distr(2,2) = Load.Chord_Pressure.Model_X_f_Value;
            case 'DISTRIBUTION'
                f_Distr = Load.Chord_Pressure.Model_X_f_Distr_Data;
        end
        
        p2_p1 = Access_Array(p2_p1_Distr, Z, Load.Extrapolation.Model_X_p2_p1_0, Load.Extrapolation.Model_X_p2_p1_1);
        p3_p1 = Access_Array(p3_p1_Distr, Z, Load.Extrapolation.Model_X_p3_p1_0, Load.Extrapolation.Model_X_p3_p1_1);
        f = Access_Array(f_Distr, Z, Load.Extrapolation.Model_X_f_0, Load.Extrapolation.Model_X_f_1);
        
        Distribution = zeros(3,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f;
        Distribution(2,2) = p2_p1;
        Distribution(3,1) = 1;
        Distribution(3,2) = p3_p1;
        
    case 'MODEL_3'
        
        switch Load.Chord_Pressure.Model_X_p2_p1_Type
            case 'CONSTANT'
                p2_p1_Distr = zeros(2,2);
                p2_p1_Distr(1,1) = 0;
                p2_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
                p2_p1_Distr(2,1) = 1;
                p2_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
            case 'DISTRIBUTION'
                p2_p1_Distr = Load.Chord_Pressure.Model_X_p2_p1_Distr_Data;
        end
        
        switch Load.Chord_Pressure.Model_X_f_Type
            case 'CONSTANT'
                f_Distr = zeros(2,2);
                f_Distr(1,1) = 0;
                f_Distr(1,2) = Load.Chord_Pressure.Model_X_f_Value;
                f_Distr(2,1) = 1;
                f_Distr(2,2) = Load.Chord_Pressure.Model_X_f_Value;
            case 'DISTRIBUTION'
                f_Distr = Load.Chord_Pressure.Model_X_f_Distr_Data;
        end
        
        p2_p1 = Access_Array(p2_p1_Distr, Z, Load.Extrapolation.Model_X_p2_p1_0, Load.Extrapolation.Model_X_p2_p1_1);
        f = Access_Array(f_Distr, Z, Load.Extrapolation.Model_X_f_0, Load.Extrapolation.Model_X_f_1);
        
        Distribution = zeros(3,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f;
        Distribution(2,2) = p2_p1;
        Distribution(3,1) = 1;
        Distribution(3,2) = 0;
        
    case 'MODEL_4'
        
        switch Load.Chord_Pressure.Model_X_f_Type
            case 'CONSTANT'
                f_Distr = zeros(2,2);
                f_Distr(1,1) = 0;
                f_Distr(1,2) = Load.Chord_Pressure.Model_X_f_Value;
                f_Distr(2,1) = 1;
                f_Distr(2,2) = Load.Chord_Pressure.Model_X_f_Value;
            case 'DISTRIBUTION'
                f_Distr = Load.Chord_Pressure.Model_X_f_Distr_Data;
        end
        
        f = Access_Array(f_Distr, Z, Load.Extrapolation.Model_X_f_0, Load.Extrapolation.Model_X_f_1);
        
        Distribution = zeros(3,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f;
        Distribution(2,2) = 0;
        Distribution(3,1) = 1;
        Distribution(3,2) = 0;
        
    case 'MODEL_5'
        
        Distribution = zeros(2,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = 1;
        Distribution(2,2) = 0;
        
    case 'MODEL_6'
        
        switch Load.Chord_Pressure.Model_X_p2_p1_Type
            case 'CONSTANT'
                p2_p1_Distr = zeros(2,2);
                p2_p1_Distr(1,1) = 0;
                p2_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
                p2_p1_Distr(2,1) = 1;
                p2_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
            case 'DISTRIBUTION'
                p2_p1_Distr = Load.Chord_Pressure.Model_X_p2_p1_Distr_Data;
        end
        
        switch Load.Chord_Pressure.Model_X_f1_Type
            case 'CONSTANT'
                f1_Distr = zeros(2,2);
                f1_Distr(1,1) = 0;
                f1_Distr(1,2) = Load.Chord_Pressure.Model_X_f1_Value;
                f1_Distr(2,1) = 1;
                f1_Distr(2,2) = Load.Chord_Pressure.Model_X_f1_Value;
            case 'DISTRIBUTION'
                f1_Distr = Load.Chord_Pressure.Model_X_f1_Distr_Data;
        end

        switch Load.Chord_Pressure.Model_X_f2_Type
            case 'CONSTANT'
                f2_Distr = zeros(2,2);
                f2_Distr(1,1) = 0;
                f2_Distr(1,2) = Load.Chord_Pressure.Model_X_f2_Value;
                f2_Distr(2,1) = 1;
                f2_Distr(2,2) = Load.Chord_Pressure.Model_X_f2_Value;
            case 'DISTRIBUTION'
                f2_Distr = Load.Chord_Pressure.Model_X_f2_Distr_Data;
        end
        
        p2_p1 = Access_Array(p2_p1_Distr, Z, Load.Extrapolation.Model_X_p2_p1_0, Load.Extrapolation.Model_X_p2_p1_1);
        f1 = Access_Array(f1_Distr, Z, Load.Extrapolation.Model_X_f1_0, Load.Extrapolation.Model_X_f1_1);
        f2 = Access_Array(f2_Distr, Z, Load.Extrapolation.Model_X_f2_0, Load.Extrapolation.Model_X_f2_1);
        
        Distribution = zeros(4,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f1;
        Distribution(2,2) = 1;
        Distribution(3,1) = f2;
        Distribution(3,2) = p2_p1;
        Distribution(4,1) = 1;
        Distribution(4,2) = p2_p1;
        
    case 'MODEL_7'
        
        switch Load.Chord_Pressure.Model_X_p2_p1_Type
            case 'CONSTANT'
                p2_p1_Distr = zeros(2,2);
                p2_p1_Distr(1,1) = 0;
                p2_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
                p2_p1_Distr(2,1) = 1;
                p2_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
            case 'DISTRIBUTION'
                p2_p1_Distr = Load.Chord_Pressure.Model_X_p2_p1_Distr_Data;
        end

        switch Load.Chord_Pressure.Model_X_p3_p1_Type
            case 'CONSTANT'
                p3_p1_Distr = zeros(2,2);
                p3_p1_Distr(1,1) = 0;
                p3_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p3_p1_Value;
                p3_p1_Distr(2,1) = 1;
                p3_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p3_p1_Value;
            case 'DISTRIBUTION'
                p3_p1_Distr = Load.Chord_Pressure.Model_X_p3_p1_Distr_Data;
        end
        
        switch Load.Chord_Pressure.Model_X_f1_Type
            case 'CONSTANT'
                f1_Distr = zeros(2,2);
                f1_Distr(1,1) = 0;
                f1_Distr(1,2) = Load.Chord_Pressure.Model_X_f1_Value;
                f1_Distr(2,1) = 1;
                f1_Distr(2,2) = Load.Chord_Pressure.Model_X_f1_Value;
            case 'DISTRIBUTION'
                f1_Distr = Load.Chord_Pressure.Model_X_f1_Distr_Data;
        end

        switch Load.Chord_Pressure.Model_X_f2_Type
            case 'CONSTANT'
                f2_Distr = zeros(2,2);
                f2_Distr(1,1) = 0;
                f2_Distr(1,2) = Load.Chord_Pressure.Model_X_f2_Value;
                f2_Distr(2,1) = 1;
                f2_Distr(2,2) = Load.Chord_Pressure.Model_X_f2_Value;
            case 'DISTRIBUTION'
                f2_Distr = Load.Chord_Pressure.Model_X_f2_Distr_Data;
        end
        
        p2_p1 = Access_Array(p2_p1_Distr, Z, Load.Extrapolation.Model_X_p2_p1_0, Load.Extrapolation.Model_X_p2_p1_1);
        p3_p1 = Access_Array(p3_p1_Distr, Z, Load.Extrapolation.Model_X_p3_p1_0, Load.Extrapolation.Model_X_p3_p1_1);

        f1 = Access_Array(f1_Distr, Z, Load.Extrapolation.Model_X_f1_0, Load.Extrapolation.Model_X_f1_1);
        f2 = Access_Array(f2_Distr, Z, Load.Extrapolation.Model_X_f2_0, Load.Extrapolation.Model_X_f2_1);
        
        Distribution = zeros(4,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f1;
        Distribution(2,2) = 1;
        Distribution(3,1) = f2;
        Distribution(3,2) = p2_p1;
        Distribution(4,1) = 1;
        Distribution(4,2) = p3_p1;
        
    case 'MODEL_8'
        
        switch Load.Chord_Pressure.Model_X_p2_p1_Type
            case 'CONSTANT'
                p2_p1_Distr = zeros(2,2);
                p2_p1_Distr(1,1) = 0;
                p2_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
                p2_p1_Distr(2,1) = 1;
                p2_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
            case 'DISTRIBUTION'
                p2_p1_Distr = Load.Chord_Pressure.Model_X_p2_p1_Distr_Data;
        end
        
        switch Load.Chord_Pressure.Model_X_f1_Type
            case 'CONSTANT'
                f1_Distr = zeros(2,2);
                f1_Distr(1,1) = 0;
                f1_Distr(1,2) = Load.Chord_Pressure.Model_X_f1_Value;
                f1_Distr(2,1) = 1;
                f1_Distr(2,2) = Load.Chord_Pressure.Model_X_f1_Value;
            case 'DISTRIBUTION'
                f1_Distr = Load.Chord_Pressure.Model_X_f1_Distr_Data;
        end

        switch Load.Chord_Pressure.Model_X_f2_Type
            case 'CONSTANT'
                f2_Distr = zeros(2,2);
                f2_Distr(1,1) = 0;
                f2_Distr(1,2) = Load.Chord_Pressure.Model_X_f2_Value;
                f2_Distr(2,1) = 1;
                f2_Distr(2,2) = Load.Chord_Pressure.Model_X_f2_Value;
            case 'DISTRIBUTION'
                f2_Distr = Load.Chord_Pressure.Model_X_f2_Distr_Data;
        end
        
        p2_p1 = Access_Array(p2_p1_Distr, Z, Load.Extrapolation.Model_X_p2_p1_0, Load.Extrapolation.Model_X_p2_p1_1);
        f1 = Access_Array(f1_Distr, Z, Load.Extrapolation.Model_X_f1_0, Load.Extrapolation.Model_X_f1_1);
        f2 = Access_Array(f2_Distr, Z, Load.Extrapolation.Model_X_f2_0, Load.Extrapolation.Model_X_f2_1);
        
        Distribution = zeros(4,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f1;
        Distribution(2,2) = 1;
        Distribution(3,1) = f2;
        Distribution(3,2) = p2_p1;
        Distribution(4,1) = 1;
        Distribution(4,2) = 0;
        
    case 'MODEL_9'
        
        switch Load.Chord_Pressure.Model_X_f1_Type
            case 'CONSTANT'
                f1_Distr = zeros(2,2);
                f1_Distr(1,1) = 0;
                f1_Distr(1,2) = Load.Chord_Pressure.Model_X_f1_Value;
                f1_Distr(2,1) = 1;
                f1_Distr(2,2) = Load.Chord_Pressure.Model_X_f1_Value;
            case 'DISTRIBUTION'
                f1_Distr = Load.Chord_Pressure.Model_X_f1_Distr_Data;
        end

        switch Load.Chord_Pressure.Model_X_f2_Type
            case 'CONSTANT'
                f2_Distr = zeros(2,2);
                f2_Distr(1,1) = 0;
                f2_Distr(1,2) = Load.Chord_Pressure.Model_X_f2_Value;
                f2_Distr(2,1) = 1;
                f2_Distr(2,2) = Load.Chord_Pressure.Model_X_f2_Value;
            case 'DISTRIBUTION'
                f2_Distr = Load.Chord_Pressure.Model_X_f2_Distr_Data;
        end
        
        f1 = Access_Array(f1_Distr, Z, Load.Extrapolation.Model_X_f1_0, Load.Extrapolation.Model_X_f1_1);
        f2 = Access_Array(f2_Distr, Z, Load.Extrapolation.Model_X_f2_0, Load.Extrapolation.Model_X_f2_1);
        
        Distribution = zeros(4,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f1;
        Distribution(2,2) = 1;
        Distribution(3,1) = f2;
        Distribution(3,2) = 0;
        Distribution(4,1) = 1;
        Distribution(4,2) = 0;
        
    case 'MODEL_10'
        
        switch Load.Chord_Pressure.Model_X_f_Type
            case 'CONSTANT'
                f_Distr = zeros(2,2);
                f_Distr(1,1) = 0;
                f_Distr(1,2) = Load.Chord_Pressure.Model_X_f_Value;
                f_Distr(2,1) = 1;
                f_Distr(2,2) = Load.Chord_Pressure.Model_X_f_Value;
            case 'DISTRIBUTION'
                f_Distr = Load.Chord_Pressure.Model_X_f_Distr_Data;
        end
        
        f = Access_Array(f_Distr, Z, Load.Extrapolation.Model_X_f_0, Load.Extrapolation.Model_X_f_1);
        
        Distribution = zeros(3,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f;
        Distribution(2,2) = 1;
        Distribution(3,1) = 1;
        Distribution(3,2) = 0;
        
    case 'MODEL_11'
        
        switch Load.Chord_Pressure.Model_X_p2_p1_Type
            case 'CONSTANT'
                p2_p1_Distr = zeros(2,2);
                p2_p1_Distr(1,1) = 0;
                p2_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
                p2_p1_Distr(2,1) = 1;
                p2_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
            case 'DISTRIBUTION'
                p2_p1_Distr = Load.Chord_Pressure.Model_X_p2_p1_Distr_Data;
        end

        switch Load.Chord_Pressure.Model_X_p3_p1_Type
            case 'CONSTANT'
                p3_p1_Distr = zeros(2,2);
                p3_p1_Distr(1,1) = 0;
                p3_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p3_p1_Value;
                p3_p1_Distr(2,1) = 1;
                p3_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p3_p1_Value;
            case 'DISTRIBUTION'
                p3_p1_Distr = Load.Chord_Pressure.Model_X_p3_p1_Distr_Data;
        end
        
        switch Load.Chord_Pressure.Model_X_f1_Type
            case 'CONSTANT'
                f1_Distr = zeros(2,2);
                f1_Distr(1,1) = 0;
                f1_Distr(1,2) = Load.Chord_Pressure.Model_X_f1_Value;
                f1_Distr(2,1) = 1;
                f1_Distr(2,2) = Load.Chord_Pressure.Model_X_f1_Value;
            case 'DISTRIBUTION'
                f1_Distr = Load.Chord_Pressure.Model_X_f1_Distr_Data;
        end

        switch Load.Chord_Pressure.Model_X_f2_Type
            case 'CONSTANT'
                f2_Distr = zeros(2,2);
                f2_Distr(1,1) = 0;
                f2_Distr(1,2) = Load.Chord_Pressure.Model_X_f2_Value;
                f2_Distr(2,1) = 1;
                f2_Distr(2,2) = Load.Chord_Pressure.Model_X_f2_Value;
            case 'DISTRIBUTION'
                f2_Distr = Load.Chord_Pressure.Model_X_f2_Distr_Data;
        end
        
        p2_p1 = Access_Array(p2_p1_Distr, Z, Load.Extrapolation.Model_X_p2_p1_0, Load.Extrapolation.Model_X_p2_p1_1);
        p3_p1 = Access_Array(p3_p1_Distr, Z, Load.Extrapolation.Model_X_p3_p1_0, Load.Extrapolation.Model_X_p3_p1_1);

        f1 = Access_Array(f1_Distr, Z, Load.Extrapolation.Model_X_f1_0, Load.Extrapolation.Model_X_f1_1);
        f2 = Access_Array(f2_Distr, Z, Load.Extrapolation.Model_X_f2_0, Load.Extrapolation.Model_X_f2_1);
        
        Distribution = zeros(5,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f1;
        Distribution(2,2) = 1;
        Distribution(3,1) = f1 + (f2 - f1)*Stair_Parameter;
        Distribution(3,2) = p2_p1;
        Distribution(4,1) = f2;
        Distribution(4,2) = p3_p1;
        Distribution(5,1) = 1;
        Distribution(5,2) = p3_p1;
        
    case 'MODEL_12'
        
        switch Load.Chord_Pressure.Model_X_p2_p1_Type
            case 'CONSTANT'
                p2_p1_Distr = zeros(2,2);
                p2_p1_Distr(1,1) = 0;
                p2_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
                p2_p1_Distr(2,1) = 1;
                p2_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
            case 'DISTRIBUTION'
                p2_p1_Distr = Load.Chord_Pressure.Model_X_p2_p1_Distr_Data;
        end

        switch Load.Chord_Pressure.Model_X_p3_p1_Type
            case 'CONSTANT'
                p3_p1_Distr = zeros(2,2);
                p3_p1_Distr(1,1) = 0;
                p3_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p3_p1_Value;
                p3_p1_Distr(2,1) = 1;
                p3_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p3_p1_Value;
            case 'DISTRIBUTION'
                p3_p1_Distr = Load.Chord_Pressure.Model_X_p3_p1_Distr_Data;
        end

        switch Load.Chord_Pressure.Model_X_p4_p1_Type
            case 'CONSTANT'
                p4_p1_Distr = zeros(2,2);
                p4_p1_Distr(1,1) = 0;
                p4_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p4_p1_Value;
                p4_p1_Distr(2,1) = 1;
                p4_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p4_p1_Value;
            case 'DISTRIBUTION'
                p4_p1_Distr = Load.Chord_Pressure.Model_X_p4_p1_Distr_Data;
        end
        
        switch Load.Chord_Pressure.Model_X_f1_Type
            case 'CONSTANT'
                f1_Distr = zeros(2,2);
                f1_Distr(1,1) = 0;
                f1_Distr(1,2) = Load.Chord_Pressure.Model_X_f1_Value;
                f1_Distr(2,1) = 1;
                f1_Distr(2,2) = Load.Chord_Pressure.Model_X_f1_Value;
            case 'DISTRIBUTION'
                f1_Distr = Load.Chord_Pressure.Model_X_f1_Distr_Data;
        end

        switch Load.Chord_Pressure.Model_X_f2_Type
            case 'CONSTANT'
                f2_Distr = zeros(2,2);
                f2_Distr(1,1) = 0;
                f2_Distr(1,2) = Load.Chord_Pressure.Model_X_f2_Value;
                f2_Distr(2,1) = 1;
                f2_Distr(2,2) = Load.Chord_Pressure.Model_X_f2_Value;
            case 'DISTRIBUTION'
                f2_Distr = Load.Chord_Pressure.Model_X_f2_Distr_Data;
        end
        
        p2_p1 = Access_Array(p2_p1_Distr, Z, Load.Extrapolation.Model_X_p2_p1_0, Load.Extrapolation.Model_X_p2_p1_1);
        p3_p1 = Access_Array(p3_p1_Distr, Z, Load.Extrapolation.Model_X_p3_p1_0, Load.Extrapolation.Model_X_p3_p1_1);
        p4_p1 = Access_Array(p4_p1_Distr, Z, Load.Extrapolation.Model_X_p4_p1_0, Load.Extrapolation.Model_X_p4_p1_1);

        f1 = Access_Array(f1_Distr, Z, Load.Extrapolation.Model_X_f1_0, Load.Extrapolation.Model_X_f1_1);
        f2 = Access_Array(f2_Distr, Z, Load.Extrapolation.Model_X_f2_0, Load.Extrapolation.Model_X_f2_1);
        
        Distribution = zeros(5,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f1;
        Distribution(2,2) = 1;
        Distribution(3,1) = f1 + (f2 - f1)*Stair_Parameter;
        Distribution(3,2) = p2_p1;
        Distribution(4,1) = f2;
        Distribution(4,2) = p3_p1;
        Distribution(5,1) = 1;
        Distribution(5,2) = p4_p1;
        
    case 'MODEL_13'
        
        switch Load.Chord_Pressure.Model_X_p2_p1_Type
            case 'CONSTANT'
                p2_p1_Distr = zeros(2,2);
                p2_p1_Distr(1,1) = 0;
                p2_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
                p2_p1_Distr(2,1) = 1;
                p2_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
            case 'DISTRIBUTION'
                p2_p1_Distr = Load.Chord_Pressure.Model_X_p2_p1_Distr_Data;
        end

        switch Load.Chord_Pressure.Model_X_p3_p1_Type
            case 'CONSTANT'
                p3_p1_Distr = zeros(2,2);
                p3_p1_Distr(1,1) = 0;
                p3_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p3_p1_Value;
                p3_p1_Distr(2,1) = 1;
                p3_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p3_p1_Value;
            case 'DISTRIBUTION'
                p3_p1_Distr = Load.Chord_Pressure.Model_X_p3_p1_Distr_Data;
        end
        
        switch Load.Chord_Pressure.Model_X_f1_Type
            case 'CONSTANT'
                f1_Distr = zeros(2,2);
                f1_Distr(1,1) = 0;
                f1_Distr(1,2) = Load.Chord_Pressure.Model_X_f1_Value;
                f1_Distr(2,1) = 1;
                f1_Distr(2,2) = Load.Chord_Pressure.Model_X_f1_Value;
            case 'DISTRIBUTION'
                f1_Distr = Load.Chord_Pressure.Model_X_f1_Distr_Data;
        end

        switch Load.Chord_Pressure.Model_X_f2_Type
            case 'CONSTANT'
                f2_Distr = zeros(2,2);
                f2_Distr(1,1) = 0;
                f2_Distr(1,2) = Load.Chord_Pressure.Model_X_f2_Value;
                f2_Distr(2,1) = 1;
                f2_Distr(2,2) = Load.Chord_Pressure.Model_X_f2_Value;
            case 'DISTRIBUTION'
                f2_Distr = Load.Chord_Pressure.Model_X_f2_Distr_Data;
        end
        
        p2_p1 = Access_Array(p2_p1_Distr, Z, Load.Extrapolation.Model_X_p2_p1_0, Load.Extrapolation.Model_X_p2_p1_1);
        p3_p1 = Access_Array(p3_p1_Distr, Z, Load.Extrapolation.Model_X_p3_p1_0, Load.Extrapolation.Model_X_p3_p1_1);

        f1 = Access_Array(f1_Distr, Z, Load.Extrapolation.Model_X_f1_0, Load.Extrapolation.Model_X_f1_1);
        f2 = Access_Array(f2_Distr, Z, Load.Extrapolation.Model_X_f2_0, Load.Extrapolation.Model_X_f2_1);
        
        Distribution = zeros(5,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f1;
        Distribution(2,2) = 1;
        Distribution(3,1) = f1 + (f2 - f1)*Stair_Parameter;
        Distribution(3,2) = p2_p1;
        Distribution(4,1) = f2;
        Distribution(4,2) = p3_p1;
        Distribution(5,1) = 1;
        Distribution(5,2) = 0;
        
    case 'MODEL_14'
        
        switch Load.Chord_Pressure.Model_X_p2_p1_Type
            case 'CONSTANT'
                p2_p1_Distr = zeros(2,2);
                p2_p1_Distr(1,1) = 0;
                p2_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
                p2_p1_Distr(2,1) = 1;
                p2_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
            case 'DISTRIBUTION'
                p2_p1_Distr = Load.Chord_Pressure.Model_X_p2_p1_Distr_Data;
        end
        
        switch Load.Chord_Pressure.Model_X_f1_Type
            case 'CONSTANT'
                f1_Distr = zeros(2,2);
                f1_Distr(1,1) = 0;
                f1_Distr(1,2) = Load.Chord_Pressure.Model_X_f1_Value;
                f1_Distr(2,1) = 1;
                f1_Distr(2,2) = Load.Chord_Pressure.Model_X_f1_Value;
            case 'DISTRIBUTION'
                f1_Distr = Load.Chord_Pressure.Model_X_f1_Distr_Data;
        end

        switch Load.Chord_Pressure.Model_X_f2_Type
            case 'CONSTANT'
                f2_Distr = zeros(2,2);
                f2_Distr(1,1) = 0;
                f2_Distr(1,2) = Load.Chord_Pressure.Model_X_f2_Value;
                f2_Distr(2,1) = 1;
                f2_Distr(2,2) = Load.Chord_Pressure.Model_X_f2_Value;
            case 'DISTRIBUTION'
                f2_Distr = Load.Chord_Pressure.Model_X_f2_Distr_Data;
        end
        
        p2_p1 = Access_Array(p2_p1_Distr, Z, Load.Extrapolation.Model_X_p2_p1_0, Load.Extrapolation.Model_X_p2_p1_1);
        f1 = Access_Array(f1_Distr, Z, Load.Extrapolation.Model_X_f1_0, Load.Extrapolation.Model_X_f1_1);
        f2 = Access_Array(f2_Distr, Z, Load.Extrapolation.Model_X_f2_0, Load.Extrapolation.Model_X_f2_1);
        
        Distribution = zeros(5,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f1;
        Distribution(2,2) = 1;
        Distribution(3,1) = f1 + (f2 - f1)*Stair_Parameter;
        Distribution(3,2) = p2_p1;
        Distribution(4,1) = f2;
        Distribution(4,2) = 0;
        Distribution(5,1) = 1;
        Distribution(5,2) = 0;
        
    case 'MODEL_15'
        
        switch Load.Chord_Pressure.Model_X_p2_p1_Type
            case 'CONSTANT'
                p2_p1_Distr = zeros(2,2);
                p2_p1_Distr(1,1) = 0;
                p2_p1_Distr(1,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
                p2_p1_Distr(2,1) = 1;
                p2_p1_Distr(2,2) = Load.Chord_Pressure.Model_X_p2_p1_Value;
            case 'DISTRIBUTION'
                p2_p1_Distr = Load.Chord_Pressure.Model_X_p2_p1_Distr_Data;
        end
        
        switch Load.Chord_Pressure.Model_X_f_Type
            case 'CONSTANT'
                f_Distr = zeros(2,2);
                f_Distr(1,1) = 0;
                f_Distr(1,2) = Load.Chord_Pressure.Model_X_f_Value;
                f_Distr(2,1) = 1;
                f_Distr(2,2) = Load.Chord_Pressure.Model_X_f_Value;
            case 'DISTRIBUTION'
                f_Distr = Load.Chord_Pressure.Model_X_f_Distr_Data;
        end
        
        p2_p1 = Access_Array(p2_p1_Distr, Z, Load.Extrapolation.Model_X_p2_p1_0, Load.Extrapolation.Model_X_p2_p1_1);
        f = Access_Array(f_Distr, Z, Load.Extrapolation.Model_X_f_0, Load.Extrapolation.Model_X_f_1);
        
        Distribution = zeros(4,2);
        Distribution(1,1) = 0;
        Distribution(1,2) = 1;
        Distribution(2,1) = f;
        Distribution(2,2) = 1;
        Distribution(3,1) = f + (1 - f)*Stair_Parameter;
        Distribution(3,2) = p2_p1;
        Distribution(4,1) = 1;
        Distribution(4,2) = 0;
    
end
